﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace PrisonDefence.Models.Modifiers
{
    public class Rotator : IModifier
    {
        private Vector3 temp = Vector3.Zero;
        public Vector3 Position { get; set; }
        public Vector3 Rotation { get; set; }

        public void Update(Light light)
        {
            if (light.Type == Prison.Defence.Content.Pipleline.DataTypes.LightType.Point)
            {
                if (temp == Vector3.Zero && Position != Vector3.Zero)
                    temp = Vector3.Transform(temp, Matrix.CreateTranslation(Position));

                light.Position -= temp;
                temp = Vector3.Transform(temp, 
                    Matrix.CreateRotationX(Rotation.X) * Matrix.CreateRotationY(Rotation.Y) * Matrix.CreateRotationZ(Rotation.Z));
                light.Position += temp;

                System.Diagnostics.Debug.WriteLine(light.Position);
            }
            else
            {
                light.Direction = Vector3.Transform(light.Direction,
                    Matrix.CreateRotationX(Rotation.X) * Matrix.CreateRotationY(Rotation.Y) * Matrix.CreateRotationZ(Rotation.Z));
            }
        }

        public void Update(ModelInstance model)
        {
            throw new NotImplementedException();
        }
    }
}
